﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace nSin.TaskSwitcher
{
    using System.IO;
    using System.Runtime.Serialization.Formatters.Binary;
    // 
    [Serializable()]
    public class TabItemMetaData : ICloneable
    {

        #region " Declarations "

        private string _strApplicationName = string.Empty;
        private string _strTabHeader = string.Empty;
        private string _strUserControlFormName = string.Empty;
        private int _intTabControlIndex;
        private int _intInstanceCount;

        #endregion

        #region " Properties "

        public int InstanceCount
        {
            get { return _intInstanceCount; }
            set { _intInstanceCount = value; }
        }

        public int TabControlIndex
        {
            get { return _intTabControlIndex; }
            set { _intTabControlIndex = value; }
        }

        public string ApplicationName
        {
            get { return _strApplicationName; }
        }

        public string TabHeader
        {
            get { return _strTabHeader; }
        }

        public string UserControlFormName
        {
            get { return _strUserControlFormName; }
        }

        #endregion

        #region " Constructor "

        public TabItemMetaData(string strApplicationName, string strTabHeader, string strUserControlFormName)
        {
            _strApplicationName = strApplicationName;
            _strTabHeader = strTabHeader;
            _strUserControlFormName = strUserControlFormName;

        }

        #endregion

        #region " Events "

        //this is a little hack. it allows callers to call this 
        //method directly and get back a strongly typed object 
        public TabItemMetaData Clone()
        {
            return (TabItemMetaData)Clone1();

        }

        //this is a little hack. it allows callers to call this 
        //method using the Interface. 
        private object Clone1()
        {

            object obj = null;
            using (MemoryStream ms = new MemoryStream())
            {

                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, this);
                ms.Position = 0;
                obj = bf.Deserialize(ms);
            }
            return obj;

        }
        object System.ICloneable.Clone()
        {
            return Clone1();
        }

        #endregion

    } 
}
